package cn.edu.nyist.service.impl;

import cn.edu.nyist.entity.CommonUser;
import cn.edu.nyist.entity.Region;
import cn.edu.nyist.mapper.RegionMapper;
import cn.edu.nyist.service.RegionService;
import cn.edu.nyist.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (Region)表服务实现类
 *
 * @author makejava
 * @since 2021-03-21 17:55:26
 */
@Service("regionService")
public class RegionServiceImpl implements RegionService {

    @Autowired
    private RegionMapper regionMapper;

    @Override
    public PageBean<Region> queryPage(Map<String, Object> paramMap) {
        PageBean<Region> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Region> datas = regionMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = regionMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;

    }

    @Override
    public List<Region> queryAllRegion() {
        return regionMapper.queryAllRegion();
    }

    @Override
    public int insertRegion(Region region) {
        return regionMapper.insertRegion(region);
    }

    @Override
    public Region selectById(Integer id) {
        return regionMapper.selectById(id);
    }

    @Override
    public int delByRegionIds(List<Integer> ids) {
        return regionMapper.delByRegionIds(ids);
    }

    @Override
    public int editByRegion(Region region) {
        return regionMapper.editByRegion(region);
    }

    @Override
    public Region selectByRegionName(String regionName) {
        return regionMapper.selectByRegionName(regionName);
    }
}